package com.twohand.admin.Config;


import com.twohand.admin.Interceptor.Request;
import com.twohand.admin.Interceptor.TokenInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@SpringBootConfiguration
public class Interceptor implements WebMvcConfigurer {
    @Autowired
    Request request;
    @Autowired
    TokenInterceptor tokenInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(request);
        registry.addInterceptor(tokenInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns(
                        "/**/login/?**",
                        "/**/mini/login",
                        "/swagger-ui/**",
                        "/swagger-resources/**",
                        "/v3/**",
                        "/api/project",
                        "/api/resume/**",
                        "/api/project/**",
                        "/article/api/**",
                        "/api/h5/**",
                        "/r/**",
                        "/web/**",
                        "/"
                )
        .excludePathPatterns("/upload/**");
    }
}
